<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        // 计算从你到千锋的时间到此刻 有多少天多少时多少分多少秒
        // 正计时
        setInterval(function(){
            var time1 = new Date('2021-06-27 15:00:00')
            var time2 = new Date();
            time1 = time1.getTime();
            time2 = time2.getTime();
            var time = parseInt((time2-time1)/1000);
            var day = parseInt(time/86400);
            var hour = parseInt((time%86400)/3600);
            var min = parseInt((time%3600)/60);
            var sec = parseInt(time%60);
            document.body.innerHTML = "在南京已生活"+double(day)+"天"+double(hour)+"小时"+double(min)+"分"+double(sec)+"秒";
        }, 1000);
        function double(num){
            if(num<10){
                return "0"+num;
            }else{
                return num;
            }
        }


        // 编写一个函数，获得一个十六进制的随机颜色的字符串(例如：#20CD4F)
        // 十六进制一般用数字0到9和字母A到F（或a-f）表示，其中:A-F表示10-15，这些称作十六进制数字。
        // var arr = [0,1,2,3,4,5,6,7,8,9, 'A', 'B', 'C', 'D', 'E', 'F']
        var str = "0123456789ABCDEF";
        function ys(){
            var color = ["#"];
            for(i=1;i<7;i++){
                var n = Math.floor(Math.random()*(15-0+1)+0)
                color.push(str[n]);
            }
            var arr = color.join('');
            return arr;
        }
        document.body.innerHTML = ys();
    </script>
</body>
</html>